//
//  HMVisitorController.swift
//  weibo10
//
//  Created by mac on 15/10/17.
//  Copyright © 2015年 itheima. All rights reserved.
//

import UIKit

class HMVisitorController: UITableViewController {
    var visitorView: HMVisitorView?
    // 用户登录标记
    private var useLogo = HMUserAcountViewModel.sharedUserAccount.userLogon
    override func loadView() {
        
        useLogo ? super.loadView() : setupVisitorView()
    }
    private func setupVisitorView(){
        visitorView = HMVisitorView()
        // visitorView?.delegate = self
        visitorView?.registBtn.addTarget(self, action: Selector("visitorViewDidRegistor"), forControlEvents: UIControlEvents.TouchUpInside)
        visitorView?.loginBtn.addTarget(self, action: Selector("visitorViewDidLogin"), forControlEvents: UIControlEvents.TouchUpInside)
        // 导航栏按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style:.Plain, target: self, action: Selector("visitorViewDidRegistor"))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: Selector("visitorViewDidLogin"))
        view = visitorView
        
    }
}
/// MARK -监听按钮点击
extension HMVisitorController{
    func visitorViewDidRegistor() {
        print("注册按钮点击")
    }
    func visitorViewDidLogin() {
        
        let vc = HMOAuthViewController()
        
        let nav = UINavigationController(rootViewController: vc)
        presentViewController(nav, animated: true, completion: nil)
    }
}